﻿using UnityEngine;
using UnityEngine.UI;


public class SkillIcon : MonoBehaviour
{
    public SkillInfo skillInfo { private set; get; }
    public ItemInfo itemInfo { private set; get; }

    private Image mask;

    public void SetSkillInfo(SkillInfo info)
    {
        skillInfo = info;
        SetIcon(info.SkillImgRes);
    }


    public void SetItemInfo(ItemInfo item)
    {
        itemInfo = item;
        SetIcon(item.ItemImgRes);
    }

    private void SetIcon(string url)
    {
        GetComponent<Image>().sprite = Resources.Load(url, typeof(Sprite)) as Sprite;
        SetCooldown(0);
    }

    //设置冷却
    public void SetCooldown(float fill)
    {
        if (mask == null)
            mask = transform.Find("Mask").GetComponent<Image>();
        mask.fillAmount = fill;
    }
}
